<template>
  <div class="elec-app-main-list">
    <listSearch></listSearch>
    <div class="chat-list no-drag">
      <div
        v-for="(item, index) in friendList"
        :key="index"
        :class="['chat-item', activeChat == item.id ? 'active' : '']"
      >
        <img :src="item.avatar" alt="" class="avatar" />
        <div class="info">
          <div class="title">
            <div class="name">
              {{ item.name }}
            </div>
            <div class="time">{{ item.time }}</div>
          </div>
          <div class="message ellipsis">{{ item?.message }}</div>
        </div>
      </div>
    </div>
  </div>
  <div class="elec-app-main-detail">
    <router-view></router-view>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import listSearch from '@/components/listSearch/index.vue'
import { friendList } from './mock'

const activeChat = ref(5)
</script>
<style lang="less" scoped>
.elec-app-main-list {
  display: flex;
  flex-direction: column;
}
.chat-list {
  flex: 1;
  overflow-y: auto;
  .chat-item {
    display: flex;
    align-items: center;
    height: 60px;
    padding: 10px;
    &.active {
      background-color: #c9c7c6;
    }
    .avatar {
      flex-shrink: 0;
      height: 40px;
      width: 40px;
      border-radius: 2px;
      margin-right: 10px;
    }
    .info {
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      width: calc(100% - 50px);
      height: 100%;
      user-select: none;
      .title {
        display: flex;
        justify-content: space-between;
        .name {
          font-size: 14px;
        }
        .time {
          font-size: 12px;
          color: #b0b0b0;
        }
      }
      .message {
        font-size: 12px;
        color: #909090;
        width: 100%;
      }
    }
  }
}
</style>
